<?php
require_once("DButil.php");

$sql="select p_id,p_name,p_price,p_unit,p_image_url,p_image from product";
$conn=getConn();
$result=mysqli_query($conn,$sql);

header("Content-Type:application/json;charset=utf-8");

if($result){
    $num=mysqli_num_rows($result);
    for($i=0;$i<$num;$i++){
        $row= mysqli_fetch_assoc($result);
        $name=$row['p_name'];
        $value= json_encode($row);
        $expire = time() + 7*24*60*60;
        $path = "/"; 
        setcookie($name, $value, $expire, $path);
    }
    
}

// var_dump($_COOKIE);
// echo "<br>";
$str=$_COOKIE["测试"];
$jq=json_decode($str);
var_dump($jq);
mysqli_close($conn);

?>

